APP = gmtm

CC = gcc
CFLAGS = -Wall -g -O2 -lgd -lpng -lz -ljpeg -lfreetype -lm
OBJECTS = gmtm.o args.o util.o img.o
OUT = $(APP)

prefix = /usr
bindir = $(prefix)/bin
docdir = $(prefix)/share/doc/$(APP)
mandir = $(prefix)/share/man/man1

gmtm: $(OBJECTS)
	$(CC) $(CFLAGS) $(OBJECTS) -o $(OUT)

%.o: src/%.c
	$(CC) $(CFLAGS) -c $<

all: gmtm

clean:
	rm -f $(OBJECTS) $(OUT)

install:
	install $(OUT) $(bindir)
	mkdir -p $(docdir)
	install -m 644 LICENSE $(docdir)
	mkdir -p $(mandir)
	install -m 644 man/gmtm.1 $(mandir)
	gzip -f -9 $(mandir)/gmtm.1

uninstall:
	rm -f $(bindir)/$(OUT)
	rm -rf $(docdir)
	rm -f $(mandir)/gmtm.1.gz

package-deb: gmtm
	./buildpackage -D

package-rpm: gmtm
	./buildpackage -R

package-slack: gmtm
	./buildpackage -S

